<template>
	<view class="swiper-content">
		<!-- <view class="hander-top p-lr-32 w-s flex-j-sb--a-ct">
			<view class="count">{{currentImg + 1}} / {{ imgs.length }}</view>
		</view> -->
		

		<swiper class="swiper-img" indicator-dots indicator-color="#D8D8D8" indicator-active-color="#FFFFFF" :current="currentImg" :duration="300" @change="changeSwiper">
			<swiper-item class="swiper-item" v-for="(item, index) in imgs" :key="index">
				<view class="img-page">
					<movable-area scale-area>
						<movable-view direction="all" scale="true" scale-min="1" scale-max="4">
							<image class="max-img" :src="item.image" :lazy-load="true" mode="aspectFill" />
						</movable-view>
					</movable-area>
					<view class="bigName">
						{{item.name}}
					</view>
				</view>
			</swiper-item>
		</swiper>
		<view class="item-bottom">
			<scroll-view class="scroll-view_H " :scroll-x="true" :scroll-into-view="scrollTopIndex"
				:scroll-with-animation="true" scroll-left="20" >
				<view class="img-page-box scroll-view-item_H" 
					v-for="(item, index) in imgs" :key="index" :id="`scrollToIndex${index}`" @click.stop="toImg(index)">
					<image class="img" :src="item.image" mode="aspectFill" />
					<view class="name" :class="currentImg == index ? 'nameChecked' : ''">
						{{item.name}}
					</view>
					<view :class="currentImg == index ? 'img-page-checked' : ''"></view>
				</view>
			</scroll-view> 
		</view>

		

	</view>
</template>

<script>
	export default {
		props: {
			imgs: {
				type: Array,
				default: []
			},
			currentIndex: {
				type: Number,
				default: 0
			},
		},
		data() {
			return {
				// imgs: [
				// 	"https://pic2.zhimg.com/80/v2-6bc06520079e780ac1c550729f5cfa8d_1440w.webp",
				// 	"https://img.tukuppt.com/photo-big/00/02/23/6188eaff33ec07243.jpg",
				// 	"https://img0.baidu.com/it/u=4231555811,1903718579&fm=253&app=138&size=w931",
				// 	"https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2022%2F0509%2F1e1bac6cj00rbkpwf001ec000hs00q8c.jpg&thumbnail=660x2147483647&quality=80&type=jpg",
				// 	"https://pic2.zhimg.com/80/v2-6bc06520079e780ac1c550729f5cfa8d_1440w.webp",
				// 	"https://img.tukuppt.com/photo-big/00/02/23/6188eaff33ec07243.jpg",
				// 	"https://img0.baidu.com/it/u=4231555811,1903718579&fm=253&app=138&size=w931",
				// 	"https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2022%2F0509%2F1e1bac6cj00rbkpwf001ec000hs00q8c.jpg&thumbnail=660x2147483647&quality=80&type=jpg",
				// ],
				currentImg: 0,
				isPop: false,
				scrollTopIndex: "",

				isScale: false,
				isCollect: false,
				isLike: false,
			};
		},
		created() {
			// let { imgs, current } = options;
			// this.imgs = JSON.parse(imgs);
			// this.currentImg = current;
			
		},
		mounted() {
			// this.currentImg = this.currentIndex
			this.currentImg = 0
			
		},
		methods: {
			changeSwiper(e) {
				this.currentImg = e.detail.current;
				console.log("e", e);

				this.scrollTopIndex = `scrollToIndex${e.detail.current}`;
			},
			toImg(index) {
				this.currentImg = index;
			},
			onBack() {
				uni.navigateBack();
			},

		},
	};
</script>

<style lang="scss" scoped>
	.swiper-content {
		width: 100%;
		// height: 40vh;
		position: relative;
		padding: 0 10rpx;
	}

	movable-view {
		display: flex;
		align-items: center;
		justify-content: center;

		width: 100%;
		height: 100%;
	}

	movable-area {
		position: fixed;

		overflow: hidden;

		width: 100%;
		height: 100%;

		transform: scale();
	}

	movable-view image {
		width: 100%;
	}

	uni-image>img {
		z-index: -1 !important;
	}

	.hander-top {
		position: absolute;
		z-index: 1000;
		top: 28rpx;
		left: 0;
		display: flex;
		justify-content: space-between;
		width: 100%;
		padding: 0 32rpx;
		box-sizing: border-box;

		.icon-back-wrap {
			width: 64rpx;
			height: 64rpx;

			.icon-back {
				width: 64rpx;
				height: 64rpx;
			}
		}

		.count {
			box-sizing: border-box;
			padding: 8rpx 24rpx;

			color: #fff;
			border-radius: 24rpx;
			background: rgba(0, 0, 0, .4);

			font-size: 28rpx;
			height: 50rpx;
		}
	}
	.hander-top1{
		position: absolute;
		z-index: 1000;
		top: 28rpx;
		left: 28rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #3898FF;
	}

	.swiper-img {
		// width: 100vw;
		height: 40vh;
		background-color: #000;

		.swiper-item {
			// width: 100vw;
			height: 40vh;

			.img-page {
				display: flex;
				align-items: center;
                 position: relative;
				// width: 100vw;
				height: 40vh;
                .bigName{
					position: absolute;
					top:0rpx;
					left:0rpx;
					font-weight: bold;
					color: #FFFFFF ;
					font-size: 32rpx;
					padding:0 12rpx;
					line-height: 48rpx;
					background: rgba(0,0,0,.3);
					border-top-left-radius: 8rpx;
					border-bottom-right-radius: 8rpx;
				}
				.max-img {
					width: 100%;
					height: 100%;
				}
			}
		}
	}


	.item-bottom {
		// position: fixed;
		// z-index: 9999;
		// bottom:10rpx;
		// left: 0rpx;

		display: flex;
		flex-direction: column;
		justify-content: space-between;

		width: 96vw;

		 // height: 200rpx;
		// padding: 0 30rpx;

		transition: ease-in-out .3s;
	}

	.small-list-page {
		min-height: 60rpx;
	}

	.scroll-Y {
		height: 300rpx;
	}

	.scroll-view_H {
		width: 100%;
		box-sizing: border-box;
		padding-right: 32rpx;
		white-space: nowrap;
	}

	.scroll-view-item_H {
		display: inline-block;

		margin-right: 10rpx;

		transition: ease-in .1s;
		transform: scale(.8);

		border-radius: 11rpx;
		// background: #c2c2c2;

		&:last-child {
			margin-right: 0;
		}

		.img {
			display: block;
			width: 160rpx;
			height: 190rpx;
			border:1px solid #ddd;
			border-radius: 8rpx;
		}
		.name{
			position: absolute;
			left:0rpx;
			top: 0rpx;
			font-weight: bold;
			color: #FFFFFF ;
			font-size: 20rpx;
			padding:0 8rpx;
			background: rgba(0,0,0,.3);
			border-top-left-radius: 8rpx;
			
		}
		.nameChecked{
			color:#7E61EF;
		}
	}

	.img-page-checked {
		// transform: translateY(-28rpx) scale(1);
		width: 50rpx;
		height: 6rpx;
		border-radius: 6rpx;
		background-color:#3898FF ;
		position: absolute;
		top: 90%;
		left: 50%;
		transform: translate(-50%,-50%);
		
	}

	
</style>